package com.shenzhen.horselive.ui.dialog;

import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.shenzhen.horselive.R;
import com.shenzhen.horselive.databinding.DialogShareBinding;

public class ShareDialog extends Dialog {

    DialogShareBinding  binding;
    private  OnClick  onClick;
    public ShareDialog(@NonNull Context context) {
        super(context, R.style.CommonDialog);
        binding = DialogShareBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());
        binding.imgWeixin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                if (onClick!=null)
                {
                    onClick.onDuihua();
                }
            }
        });

        binding.imgQuan.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                if (onClick!=null)
                {
                    onClick.onQuan();
                }
            }
        });

    }

    public void setOnClick(OnClick onClick) {
        this.onClick = onClick;
    }

    public ShareDialog(@NonNull Context context, int themeResId) {
        super(context, themeResId);
    }

    protected ShareDialog(@NonNull Context context, boolean cancelable, @Nullable OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
    }



    @Override
    public void show() {
        super.show();
        WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
        layoutParams.width= ViewGroup.LayoutParams.MATCH_PARENT;
        layoutParams.height= ViewGroup.LayoutParams.WRAP_CONTENT;
        layoutParams.gravity = Gravity.BOTTOM;
        getWindow().setAttributes(layoutParams);
    }



    public   interface  OnClick{
      void   onDuihua();
        void   onQuan();
    }

}
